package com.qk.ezbuy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qk.ezbuy.dao.NewsMapper;
import com.qk.ezbuy.pojo.News;
import com.qk.ezbuy.pojo.User;
import com.qk.ezbuy.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NewsServiceImpl implements NewsService {
    @Autowired
    private NewsMapper newsMapper;

    @Override
    public PageInfo<News> selectPage(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<News> list = newsMapper.selectAll();
        PageInfo<News> pageInfo = new PageInfo<>(list,3);
        return pageInfo;
    }

    /**
     * 根据id查询资讯详情
     */
    @Override
    public News selectNews(int id) {
        return newsMapper.selectNews(id);
    }

    @Override
    public int updateByPrimaryKeySelective(News record) {
        return newsMapper.updateByPrimaryKeySelective(record);
    }

    /**
     * 根据id删除资讯
     * @param id
     * @return
     */
    @Override
    public int delNews(int id) {
        return newsMapper.delNews(id);
    }

    /**
     * 增加资讯
     */
    @Override
    public int insertSelective(News record) {
        return newsMapper.insertSelective(record);
    }


}
